﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ManageReservations.aspx.cs" Inherits="LuxuryResort.WebSite.Members.ManageReservations" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <!-- add styles -->
    <link href="../Styles/jquery-ui-1.10.4.custom.min.css" rel="stylesheet" type="text/css" />
    <!-- add scripts -->
    <script src="../Scripts/jquery-ui-1.10.4.custom.min.js"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h1>
        Reservations Management
    </h1>
    <fieldset>
        <legend>Reservations</legend>
        <asp:ListView ID="lvReservations" runat="server" 
                      OnItemCommand="lvReservations_ItemCommand">
            <LayoutTemplate>
                <table class="roomList">
                    <tr valign="top">
                        <th style="width: 10%">
                            Customer Name
                        </th>
                        <th>
                            Room No
                        </th>
                        <th>
                            Room Type
                        </th>
                        <th>
                            Quantity
                        </th>
                        <th>
                            Payment Method
                        </th>
                        <th>
                            Status
                        </th>
                        <th>
                            Check In
                        </th>
                        <th>
                            Check Out
                        </th>
                        <th>
                            Payment Done
                        </th>
                        <th>
                            Total
                        </th>
                        <th>
                            &nbsp;
                        </th>
                    </tr>
                    <tr runat="server" id="itemPlaceholder">
                    </tr>
                </table>
            </LayoutTemplate>
            <ItemTemplate>
                <tr>
                    <td style="text-align: center; width: 10%;">
                        <asp:Label ID="lblCustomerName" runat="server" Text='<%#Eval("CustomerName") %>' />
                    </td>
                    <td>
                        <asp:Label ID="lblRoomNo" runat="server" Text='<%#Eval("RoomNo") %>' />
                    </td>
                    <td>
                        <asp:Label ID="lblRoomType" runat="server" Text='<%#Eval("RoomType") %>' />
                        <asp:HiddenField ID="hidRoomPrice" runat="server" Value='<%#Eval("RoomPrice") %>' />
                    </td>
                    <td>
                        <asp:Label ID="lblQty" runat="server" Text='<%#Eval("Quantity") %>' />
                    </td>
                    <td>
                        <asp:Label ID="lblPaymentMethod" runat="server" Text='<%#Eval("PaymentMethod") %>' />
                    </td>
                    <td>
                        <asp:Label ID="lblStatus" runat="server" Text='<%#Eval("Status") %>' />
                        <asp:HiddenField ID="hidStatus" runat="server" Value='<%#Eval("Status") %>' />
                    </td>
                    <td>
                        <asp:Label ID="lblCheckIn" runat="server" Text='<%#Eval("CheckIn") %>' />
                    </td>
                    <td>
                        <asp:Label ID="lblCheckOut" runat="server" Text='<%#Eval("CheckOut") %>' />
                    </td>
                    <td>
                        <asp:Label ID="lblPaymentDone" runat="server" Text='<%#(bool) Eval("PaymentDone") == false ? "No" : "Yes" %>' />
                        <asp:HiddenField ID="hidPaymentDone" runat="server" Value='<%#Eval("PaymentDone") %>' />
                    </td>
                    <td>
                        <asp:Label ID="lblTotal" runat="server" Text='<%#Eval("Total") %>' />
                    </td>
                    <td style="text-align: center; width: 10%;">
                        <asp:LinkButton ID="lnkEdit" runat="server" Text="Edit" CommandName="EditReservation" CausesValidation="False"></asp:LinkButton>
                        <asp:LinkButton ID="lnkDelete" runat="server" Text="Delete" CommandName="DeleteReservation" CausesValidation="False"></asp:LinkButton>
                        <asp:HiddenField ID="hidReservationId" runat="server" Value='<%#Eval("RSID") %>' />
                        <asp:HiddenField ID="hidRoomId" runat="server" Value='<%#Eval("RMID") %>' />
                    </td>
                </tr>
            </ItemTemplate>
        </asp:ListView>
        <asp:DataPager ID="pgReservations" runat="server" PagedControlID="lvReservations" PageSize="10"
                       OnPreRender="DataPagerReservations_PreRender">
            <Fields>
                <asp:NextPreviousPagerField ShowFirstPageButton="True" ShowNextPageButton="False" />
                <asp:NumericPagerField />
                <asp:NextPreviousPagerField ShowLastPageButton="True" ShowPreviousPageButton="False" />
            </Fields>
        </asp:DataPager>
    </fieldset>
    <span id="lblMessage" class="failureNotification"></span>
    <div runat="server" id="divReservationInformation" Visible="False">
        <fieldset>
            <legend>Reservation Information</legend>
            <table width="100%" class="roomInformation">
                <tr>
                    <td style="width: 20%">
                        Room Number
                    </td>
                    <td style="width: 40%">
                        <b>
                            <asp:Label ID="lblRoomNumber" runat="server"></asp:Label></b>
                    </td>
                    <td>
                        Room Type
                    </td>
                    <td>
                        <b>
                            <asp:Label ID="lblRoomType" runat="server"></asp:Label></b>
                    </td>
                </tr>
                <tr>
                    <td>
                        Customer Name
                    </td>
                    <td>
                        <asp:TextBox ID="txtCustomerName" runat="server" MaxLength="100"></asp:TextBox><br />
                        <asp:RequiredFieldValidator ID="reqName" runat="server" ControlToValidate="txtCustomerName"
                                                    Display="Static" ErrorMessage="You must input Customer Name" CssClass="failureNotification"></asp:RequiredFieldValidator>
                    </td>
                    <td>
                        Payment method
                    </td>
                    <td>
                        <asp:DropDownList ID="cboPaymentMethod" runat="server">
                            <asp:ListItem Text="Cash" Value="Cash"></asp:ListItem>
                            <asp:ListItem Text="Card" Value="Card"></asp:ListItem>
                        </asp:DropDownList>
                        &nbsp;
                        
                        <asp:CheckBox ID="cbxPaymentDone" runat="server" Text="Payment Done" />
                        
                    </td>
                </tr>
                <tr>
                    <td>
                        Date From
                    </td>
                    <td>
                        <asp:TextBox ID="txtDateFrom" runat="server"></asp:TextBox>
                        <br />
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtDateFrom"
                                                    Display="Static" ErrorMessage="You must input check in date" CssClass="failureNotification"></asp:RequiredFieldValidator>
                    </td>
                    <td>
                        Date To
                    </td>
                    <td>
                        <asp:TextBox ID="txtDateTo" runat="server"></asp:TextBox><br />
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtDateTo"
                                                    Display="Static" ErrorMessage="You must input check out date" CssClass="failureNotification"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td>
                        Status</td>
                    <td>
                        <asp:DropDownList ID="ddlStatuses" runat="server">
                            <asp:ListItem Value="Booked" Text="Booked" />
                            <asp:ListItem Value="Occupied" Text="Occupied" />
                            <asp:ListItem Value="Cancelled" Text="Cancelled" />
                        </asp:DropDownList>
                    </td>
                    <td>
                        &nbsp;</td>
                    <td>
                        &nbsp;</td>
                </tr>
                <tr>
                    <td colspan="4">
                        <asp:Button ID="btnUpdate" runat="server" Text="Update Room" 
                                    onclick="btnUpdate_Click" />
                    </td>
                </tr>
            </table>
            <asp:HiddenField ID="hidRSID" runat="server" />
            <asp:HiddenField ID="hidRMID" runat="server" />
            <asp:HiddenField ID="hidRoomPrice" runat="server" />
        </fieldset>
    </div>
    <script type="text/javascript" src="~/Scripts/jquery.js"></script>
    <script type="text/javascript" src="~/Scripts/jquery.datetimepicker.js"></script>
    <script>
        $(function() {
            $.datepicker.setDefaults(
                $.extend($.datepicker.regional[''])
            );
            $('[id$="txtDateFrom"]').datepicker({ dateFormat: 'yy/mm/dd' });
            $('[id$="txtDateTo"]').datepicker({ dateFormat: 'yy/mm/dd' });
        });
    </script>
</asp:Content>